package cn.com.hbhgkj.web.struts2;

import org.apache.struts2.ServletActionContext;

import cn.com.hbhgkj.common.Pagination;
import cn.com.hbhgkj.config.Constants;
import cn.com.hbhgkj.pojo.User;

import com.opensymphony.xwork2.ActionSupport;

public class BaseAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2408135129020761346L;
	protected Pagination pagination;
	protected Boolean success;
	protected String message;

	public Pagination getPagination() {
		return pagination;
	}

	public void setPagination(Pagination pagination) {
		this.pagination = pagination;
	}

	public Boolean getSuccess() {
		return success;
	}

	public void setSuccess(Boolean success) {
		this.success = success;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	protected User getLoggedInUser() {
		return (User) ServletActionContext.getRequest().getSession()
				.getAttribute(Constants.USER_SSID);
	}

	protected void cacheUser(User user) {
		ServletActionContext.getRequest().getSession()
				.setAttribute(Constants.USER_SSID, user);
	}
	
	protected void clearUserCache(){
		ServletActionContext.getRequest().getSession().removeAttribute(Constants.USER_SSID);
	}

}
